<#assign form=JspTaglibs["http://www.springframework.org/tags/form"] />
<#assign spring=JspTaglibs["http://www.springframework.org/tags"] />
<#macro widget>
	<link rel="stylesheet" href="${springMacroRequestContext.getContextPath()}/resources/css/search_widget.css"/>
	  <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
  
    <div class="container-fluid well" id="search-widget-container">

        <@form.form action="search.html" method="GET" commandName="search">
            <@form.input id="hidden-room-count" type="hidden" value="1" path="roomCount" />
            <#if model.search_error??>
                <#if (model.search_error?size > 0)>
                    <div class="row control-group error">
                <#else>
                    <div class="row control-group">
                </#if>
            <#else>
                <div class="row control-group">
            </#if>
                <div class="span4">
                    <@form.label><@spring.message code="search.widget.form.label.destination" /></@form.label>
                    <div class="input-append">
                        <@form.input maxlength="90" type="text" class="input-large" name="search-widget-destination" id="destination" path="destination" />
                        <button id="submit-search" class="btn btn-primary" type="submit">Go!</button>
                    </div>
                    <#if model.search_error??>
                        <#if (model.search_error?size > 0)>
                            <#list model.search_error as error>
                                <div id="room1-search-error" class="text-error limit-search-widget"><@spring.message code="${error}" /></div>
                            </#list>
                        </#if>
                    </#if>
                </div>
            </div>
                <#if model.date_error??>
                    <#if (model.date_error?size > 0)>
                        <div class="control-group error">
                    <#else>
                        <div class="control-group">
                    </#if>
                <#else>
                    <div class="control-group">
                </#if>
                <@form.label><@spring.message code="search.widget.form.label.dates" /></@form.label>
                <div class="input-prepend">
                    <span class="add-on">Start:</span>
                    <@form.input id="search-widget-start"  maxlength="10" type="text" class="input-small disabled" path="startDate" />
                </div>
                <div class="input-prepend">
                    <span class="add-on">End:&nbsp;</span>
                    <@form.input id="search-widget-end"  maxlength="10" type="text" class="input-small disabled" path="endDate" />
                </div>
                <#if model.date_error??>
                    <#if (model.date_error?size > 0)>
                        <#list model.date_error as error>
                            <div id="room1-date-error" class="text-error limit-search-widget"><@spring.message code="${error}"/></div>
                        </#list>
                    </#if>
                </#if>
            </div>
            <div class="control-group">
                <@form.label><@spring.message code="search.widget.form.label.room" /></@form.label>
                <div id="search-widget-tabview" class="tabbable tabs-left">
                    <ul id="search-widget-tabs" class="nav nav-tabs">
                    	<li class="active"><a id="roomSelection1" href="#search-widget-room-tab1" data-toggle="tab"><@spring.message code="search.widget.form.tab.room" /> 1</a></li>
                    </ul>
                    <!-- TAB CONTENT -->
                    <div id="search-widget-tab-content" class="tab-content">
                        <div class="tab-pane active" id="search-widget-room-tab1">
                        <#if model.adults_error??>
                            <#if (model.adults_error?size > 0)>
                                <span class="control-group error">
                            <#else>
                                <span class="control-group">
                            </#if>
                        <#else>
                            <span class="control-group">
                        </#if>
                                <div class="input-prepend">
                                    <span class="add-on"><@spring.message code="search.widget.form.insidelabel.adults" /></span>
                                    <@form.input class="input-xmini" id="room1-adult-count" maxlength="1"
                                        type="text" value="2" onblur="updateEmptyField(this,2);"
                                        path="rooms[0].adultsCount" />
                                </div>
                            </span>
                            <#if model.children_error??>
                                <#if (model.children_error?size > 0)>
                                    <span class="control-group error">
                                <#else>
                                    <span class="control-group">
                                </#if>
                            <#else>
                                <span class="control-group">
                            </#if>
                                <div class="input-prepend">
                                    <span class="add-on"><@spring.message code="search.widget.form.insidelabel.children" /></span>
                                    <@form.input class="input-xmini" id="room1-children-count" maxlength="1"
                                        onchange="updateAgeFields(1,null);" type="text" value="3"
                                        onblur="updateEmptyField(this,0);"
                                        path="rooms[0].childrenCount" />
                                </div>
                            </span>
                            <#if model.age_error??>
                                <#if (model.age_error?size > 0)>
                                    <span class="control-group error">
                                <#else>
                                    <span class="control-group">
                                </#if>
                            <#else>
                                <span class="control-group">
                            </#if>
                                <div class="input-prepend input-append">
                                    <span class="add-on addon-double-fix" id="room1-child-age-text"><@spring.message code="search.widget.form.insidelabel.ages" /></span>
                                    <@form.input class="input-xmini"  maxlength="2" id="room1-child-age1"
                                        type="text" value="7" onblur="updateEmptyField(this,7); updateValueField(this);" path="rooms[0].childAges" />
                                    <@form.input class="input-xmini"  maxlength="2" id="room1-child-age2" type="text" value="10"
                                        onblur="updateEmptyField(this,7); updateValueField(this);" path="rooms[0].childAges" />
                                    <@form.input class="input-xmini addon-double-last-fix"  maxlength="2" id="room1-child-age3"
                                        type="text" value="2" onblur="updateEmptyField(this,7); updateValueField(this);" path="rooms[0].childAges" />
                                </div>
                            </span>
                        </div>
                    </div>
                </div>
                <#if model.adults_error??>
                    <#if (model.adults_error?size > 0)>
                        <#list model.adults_error as error>
                            <div id="room1-adults-error" class="text-error limit-search-widget"><@spring.message code="${error}"/></div>
                        </#list>
                    </#if>
                </#if>
                <#if model.children_error??>
                    <#if (model.children_error?size > 0)>
                        <#list model.children_error as error>
                            <div id="room1-children-error" class="text-error limit-search-widget"><@spring.message code="${error}"/></div>
                        </#list>
                    </#if>
                </#if>
                <#if model.age_error??>
                    <#if (model.age_error?size > 0)>
                        <#list model.age_error as error>
                            <div id="room1-age-error" class="text-error limit-search-widget"><@spring.message code="${error}"/></div>
                        </#list>
                    </#if>
                </#if>
            </div>
        </@form.form>
        <div class="btn-group center-container-fix">
            <button id="search-widget-add-room" class="btn" onclick="addRoom();" ><@spring.message code="search.widget.form.button.addroom"/></button>
            <button id="search-widget-remove-room" class="btn disabled" onclick="removeRoom();" ><@spring.message code="search.widget.form.button.removeRoom"/></button>
        </div>
    </div>
    <script src="${springMacroRequestContext.getContextPath()}/resources/js/search_widget.js"/></script>
</#macro>